package game.Actors;

import game.Config.Config;

import org.newdawn.slick.Animation;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.geom.Vector2f;
/**
 * This class represents an animationactor in the game.
 * The animationactor will perform it's animation until it reaches it's last frame.
 * Upon doing so, the animationactor will remove itself.
 * @author Sebastian Isheden and Victor Beer
 *
 */
public class AnimationActor extends Actor{
	Animation animation;
	/**
	 * Creates an animationactor based on the given position and spritesheet.
	 * @param position The position of the animationactor.
	 * @param animation The animation this actor will animate.
	 */
	public AnimationActor(Vector2f position,SpriteSheet animation) {
		super(null, position);
		this.animation = new Animation(animation,Config.STANDARD_DURATION);
		this.animation.stopAt(this.animation.getFrameCount()-1);	
	}
	@Override
	protected void draw(){
		//draw(position.x - this.image.getWidth()/2, position.y - this.image.getHeight()/2);
		animation.draw(position.x - animation.getWidth()/2,position.y - animation.getHeight()/2);
	}
	@Override
	protected void update(int delta) {
		animation.update(delta);
		if(animation.isStopped()){
			this.remove();
		}
	}
}
